package com.embhealth.controller;

import com.alibaba.dubbo.config.annotation.Reference;

import com.embhealth.constant.MessageConstant;
import com.embhealth.entity.PageResult;
import com.embhealth.entity.QueryPageBean;
import com.embhealth.entity.Result;
import com.embhealth.service.OrderListService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


@RestController
@RequestMapping("/orderlist")
public class OrderListController {
    @Reference
    private OrderListService orderListService;

    //分页查询
    @RequestMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        String[] selectDate = queryPageBean.getSelectDate();
        PageResult pageResult = orderListService.pageQuery(
                selectDate,
                queryPageBean.getSelectStatus(),
                queryPageBean.getSelectType(),
                queryPageBean.getQueryString(),
                queryPageBean.getPageSize(),
                queryPageBean.getCurrentPage());
        return pageResult;
    }

    //开关修改状态
    @RequestMapping("/changeStatus")
    public Result chanStatus(@RequestBody Map<String, Object> map) {
        try {
            orderListService.changeStatus(map);
            return new Result(true, MessageConstant.QUERY_ORDER_SUCCESS);

        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_ORDER_FAIL);
        }
    }

}
